<template>
  <div class="tab-bar-item" @click="geturl">
    <div v-if="!active"><slot name="simg"></slot></div>
    <div v-else><slot name="simg-active"></slot></div>
    <div :style="setcolor"><slot name="text"></slot></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      Isactive: true,
      textcolor:'red'
    }
  },
  props:{
    path:String
  },
  methods:{
    geturl(){
      this.$router.push(this.path)
    }
  },
  computed:{
    active(){
      return  this.$route.path.indexOf(this.path)!==-1
    },
    setcolor(){
      return this.active ?{color: this.textcolor}:{}
    }
  }
}
</script>

<style>
.tab-bar-item {
  flex: 1;
  text-align: center;
  height: 49px;
  font-size: 12px;
}
.tab-bar-item img {
  height: 24px;
  width: 24px;
}
.activet {
  color: red;
}
</style>
